package com.example.myzhugezhaofang.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.mvplibrary.adapter.BaseAdapter;
import com.example.mvplibrary.adapter.BaseViewHolder;
import com.example.myzhugezhaofang.R;
import com.example.myzhugezhaofang.bean.LikeBean;

import java.util.List;

public class LikeAdapter extends BaseAdapter<LikeBean.ListBean> {

    public LikeAdapter(List<LikeBean.ListBean> datas, Context context, int layoutId) {
        super(datas, context, layoutId);
    }

    @Override
    protected void bindData(BaseViewHolder holder, LikeBean.ListBean listBean, int position) {
        List<String> tags = listBean.getTags();
        TextView text1 = holder.getView(R.id.tv_item_like_1);
        TextView text2 = holder.getView(R.id.tv_item_like_2);
        TextView text41 = holder.getView(R.id.tv_item_like_41);
        TextView text42 = holder.getView(R.id.tv_item_like_42);
        TextView text5 = holder.getView(R.id.tv_item_like_5);
        ImageView image = holder.getView(R.id.iv_item_like);

        RecyclerView rv_tag = holder.getView(R.id.rv_tag_like);
        LinearLayoutManager manager = new LinearLayoutManager(context);
        manager.setOrientation(LinearLayoutManager.HORIZONTAL);
        rv_tag.setLayoutManager(manager);
        text1.setText(listBean.getHouse_title());
        text2.setText(listBean.getHouse_totalarea() + listBean.getHouse_totalarea_unit() + " | "
                + listBean.getHouse_room()
                + listBean.getHouse_room_unit() + " "
                + listBean.getHouse_hall()
                + listBean.getHouse_hall_unit() + " | "
                + listBean.getBorough_name());
        TagAdapter tagAdapter = new TagAdapter(context, tags);
        rv_tag.setAdapter(tagAdapter);
        text41.setText(listBean.getMin_price() + listBean.getMin_price_unit());
        text42.setText(listBean.getAverage_price() + listBean.getAverage_price_unit());
        text5.setText("委托中介：" + listBean.getAgencys().get(0).getName());
        Glide.with(context).load(listBean.getHouse_thumb()).into(image);
    }
}
